<?php include dirname(__FILE__).'/common/header.php'; ?>

<?php include dirname(__FILE__).'/common/menu.php'; ?>

var attr = {};
attr.ctrlName = '<?php echo $ctrlName ?>';

/*
| -------------------------------------------------------------------
|  List Grid
| -------------------------------------------------------------------
*/
list.grid = new ZM.FormPanel({
	url : list.baseUrl + attr.ctrlName+'/submitRecord',
	keySubmit:false,
	region:'center',
	buttonAlign:'left',
	buttons:null,
	labelWidth:150,
	defaults:{xtype:'textfield',width:400},
	submitForm:function(){
		ZM.submitForm(list.grid);
	},
	success:function(res) {
		ZM.bo.msg('成功!',res.detail);
		ZM.resetForm(list.grid);
	},
	failure:function(res) {
		//location.reload();
	},
	items:[{
		fieldLabel:'卡券号码',
		name:'card_number',
		allowBlank:false,
		enableKeyEvents: true,
		listeners : {
			'keyup': function(field,e) {
				var value = field.getValue();
				console.log(value)
				if(value.length != 16) return true;
				ZM.ajax({
					url: list.baseUrl + attr.ctrlName+'/getCardData',
					params: {card_number: field.getValue()},
					success: function(res) {
						Ext.getCmp('js_card_type').setValue(res.addon.card_type_text);
						Ext.getCmp('js_record_phone').setValue(res.addon.customer_phone);
						Ext.getCmp('js_record_name').setValue(res.addon.customer_name);
					}
				})
			}
		}
	},{
		xtype:'displayfield',
		fieldLabel:'卡券类别',
		id:'js_card_type'
	},{
		fieldLabel:'手机号',
		name:'record_phone',
		id:'js_record_phone',
		allowBlank:false
	},{
		fieldLabel:'姓名',
		name:'record_name',
		id:'js_record_name',
		allowBlank:false
	},{
		fieldLabel:'车架号',
		name:'record_frame_number',
		allowBlank:false
	},{
		fieldLabel:'车型',
		name:'record_models',
		allowBlank:false
	},{
		xtype:'button',
		text:'提交',
		hidden:!Ext.permission[(attr.ctrlName+'/submitRecord').toLowerCase()],
		style:'margin:20px 0 0 155px;',
		width:70,
		handler:function() {list.grid.submitForm();}
	}]
});

<?php include dirname(__FILE__).'/common/layout.php'; ?>
<?php include dirname(__FILE__).'/common/footer.php'; ?>